#include "stdio.h"
#include "stdlib.h"

#include "../ssd1306.c"

int
main (int argc, char *argv[])
{
  struct SSD1306_display dis1;
  int res = 0;
  
  dis1.dev_addr = 0x3c;
  SSD1306_Init (&dis1, "/dev/i2c-2");
  
  for (int i = 0; i < 20; ++i)
  {
     res = SSD1306_CreateFrame (&dis1, 0);
     if (res != 0)
     {
       printf ("Failed : Frame %d\n", i);
       return -1;
     }
     SSD1306_CleanFrame (&dis1, i);
     printf ("Passed : Frame %d\n", i);
  }
  
  for (int i = 0; i < 20; ++i)
  {
     SSD1306_DrawYX (&dis1, i, 63, 31, 1 + i);
  }
  
  for (int j = 0; j < 5; ++j)
  {
    for (int i = 0; i < 20; ++i)
    {
       res = SSD1306_UpdateDisplay (&dis1, i);
       //sleep (1);
    }
  }
  
  for (int i = 0; i < 20; ++i)
  {
    res = SSD1306_DestoryFrame (&dis1, 0);
    if (res != 0)
     {
       printf ("Failed : Frame %d Ret : %d\n", i, res);
       return -1;
     }
     printf ("Passed : Frame %d\n", i);
  }
  
  return 0;
}
